package com.eascs.admin.o2o.o2ozx.controller;

import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.eascs.admin.common.utils.StringUtils;
import com.eascs.admin.item.service.O2oPubDdItemService;
import com.eascs.admin.o2o.internal.form.PayMentForm;
import com.eascs.admin.o2o.internal.util.BaseUserUtil;
import com.eascs.admin.o2o.internal.util.StatusContexts;
import com.eascs.admin.o2o.loan.entity.O2oLoanUserEntity;
import com.eascs.admin.o2o.loan.entity.O2oLoanapplyEntity;
import com.eascs.admin.o2o.loan.service.O2oLoanUserService;
import com.eascs.admin.o2o.loan.service.O2oLoanapplyService;
import com.eascs.admin.o2o.o2ozx.serviceimpl.O2oLoadUserZxServiceImpl;
import com.eascs.admin.o2o.o2ozx.serviceimpl.O2oZxServiceImpl;
import com.eascs.admin.o2o.o2ozx.trans.O2oUserZxTransFormart;
import com.eascs.admin.o2o.recommend.entity.O2oRecommendEntity;
import com.eascs.admin.o2o.recommend.service.O2oRecommendService;
import com.eascs.admin.o2o.zx.entity.O2oLoanUserEntityZx;
import com.eascs.admin.o2o.zx.entity.O2oZxEntity;
import com.eascs.admin.o2o.zx.entity.O2oZxSulpmentEntity;
import com.eascs.admin.o2o.zx.entity.O2oZxSulpmentRecordLogEntity;
import com.eascs.admin.o2o.zx.from.AddO2oZxForm;
import com.eascs.admin.o2o.zx.vo.O2oZxVo;
import com.eascs.app.dao.PageResult;
import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.common.util.StringUtil;
import com.eascs.crm.common.custnew.entity.CustomerEntity;
import com.eascs.crm.common.custnew.service.CustomerService;
import com.eascs.crm.loanstart.form.CustomerBasicInfoForm;
import com.eascs.crm.loanstart.service.LoanStartServiceImpl;
import com.eascs.datalist.entity.O2oDataListEntity;
import com.eascs.datalist.service.O2oDataListService;
import com.eascs.file.FileTypeConstants;
import com.eascs.gaczcontract.entity.CustomerBasicInfo;
import com.eascs.notify.sms.SmsNotifier;
import com.eascs.notify.sms.SmsNotifyRequest;
import com.eascs.notify.sms.SmsNotifyResponse;
import com.eascs.notify.sms.SmsSendType;
import com.eascs.site.controller.BaseRestController;
import com.eascs.site.page.PaginationInfo;
import com.eascs.site.page.SelectDataOption;
import com.eascs.site.view.BaseRestResult;
import com.eascs.site.view.HtmlRestResult;
import com.eascs.site.view.ViewContext;
import com.eascs.site.view.button.Button;
import com.eascs.site.view.button.ButtonHelper;
import com.eascs.site.view.button.OpenButton;
import com.eascs.site.view.button.ShowButtonFilter;
import com.eascs.web.sso.User;
import com.eascs.web.sso.UserHolder;
import com.eascs.web.url.UrlHelper;
import com.eascs.workflow.common.entity.sys.ActOrgEntity;
import com.eascs.workflow.common.entity.wf.ProcessTemplate;
import com.eascs.workflow.common.service.sys.SysOrgService;
import com.eascs.workflow.common.service.sys.SysPermissionService;
import com.eascs.workflow.common.service.wf.WorkFlowService;
import com.eascs.workflow.common.vo.ModelResult;
import com.eascs.workflow.common.vo.WFRequestParam;

@RestController
@RequestMapping("/ro2ozx")
public class O2oZxRestController extends BaseRestController {

	private static final Logger logger = LoggerFactory.getLogger(O2oZxRestController.class);

	@Autowired
	LoanStartServiceImpl loanStartService;

	@Reference
	CustomerService customerService;

	@Reference
	SysOrgService sysOrgService;

	@Autowired
	BaseUserUtil userUtils;

	@Autowired
	O2oZxServiceImpl o2oZxServiceImpl;

	@Autowired
	O2oLoadUserZxServiceImpl o2oLoadUserZxServiceImpl;

	@Autowired
	private O2oDataListService o2oDataListService;

	@Autowired
	private O2oLoanUserService o2oLoanUserService;
	@Autowired
	private O2oLoanapplyService o2oLoanapplyService;

	@Reference
	private WorkFlowService workFlowService;
	@Autowired
	O2oPubDdItemService o2oPubDdItemService;

	@Reference
	SysPermissionService sysPermissionService;
	@Reference
	private SmsNotifier smsNotifier;
	@Value("${o2o.admin.wf.NewZxUrl}")
	private String NewZxUrl;

	@Autowired
	O2oRecommendService o2oRecommendService;

	@RequestMapping(value = "/saveOrupdateCustomerBasicInfo")
	public BaseRestResult<?> saveOrupdateCustomerBasicInfo(CustomerBasicInfoForm cbiForm) {
		BaseRestResult<?> result = null;
		Map<String, String> results = loanStartService.saveOrupdateCustomerBasicInfo(cbiForm);
		String flag = results.get("returnFlag");
		String customerId = results.get("customerId");
		if ("success".equals(flag)) {
			if (StringUtil.isNotBlank(cbiForm.getSaveType())) {
				result = BaseRestResult.redirect("/o2ozx/addZx?customerId=" + customerId + "&loanType=" + cbiForm.getSaveType());
			}
		} else {
			result = BaseRestResult.warn(flag);
		}
		return result;
	}

	/**
	 * 保存申请征信信息
	 * 
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/saveO2oZx", method = RequestMethod.POST)
	public BaseRestResult<String> addO2oZx(AddO2oZxForm addO2oZxForm) {
		logger.info("保存addO2oZxForm=={}", addO2oZxForm.toString());

		// loan-13098 个人征信查询优化限制

		CustomerEntity customer = customerService.queryCustomerEntityByCustomerId(addO2oZxForm.getCustomerId());
		if (customer == null) {
			return BaseRestResult.warn("crm中找不到该客户信息，请核实后在申请。");
		}

		if (!StatusContexts.O2O_BANKTYPE_BC.equals(addO2oZxForm.getZxBank())) {
			Boolean isMothSelected = o2oZxServiceImpl.isMothSelectedZX(customer.getIdNumber(), addO2oZxForm.getZxBank());
			if (isMothSelected) {
				return BaseRestResult.warn("一个自然月内在同一家银行仅能查询一次个人征信报告");
			}
		}

		logger.info("在CRM中查询数据结果：用户信息{},配偶信息{}", customer.getCustomerName(), customer.getSpouse());
		ActOrgEntity actOrgEntity = null;
		actOrgEntity = sysOrgService.getOrgByUnitNo(addO2oZxForm.getLtd());
		O2oZxEntity o2oZxEntity = new O2oZxEntity();
		o2oZxEntity.setCreateId(userUtils.getUser().getNo());
		o2oZxEntity.setCreateDate(new Date());
		o2oZxEntity.setCreateName(userUtils.getUser().getCname());
		o2oZxEntity.setIsDel(StatusContexts.O2O_NO);
		o2oZxEntity.setLtd(addO2oZxForm.getLtd());
		o2oZxEntity.setZxStatus(StatusContexts.O2O_NEW);
		o2oZxEntity.setLtdName(actOrgEntity.getOrgName());
		o2oZxEntity.setLtdCode(actOrgEntity.getUnitCode());
		o2oZxEntity.setOperatorId(addO2oZxForm.getOperatorNo());
		o2oZxEntity.setOperatorName(addO2oZxForm.getOperatorName());
		o2oZxEntity.setZxBank(addO2oZxForm.getZxBank());
		o2oZxEntity.setZxType(addO2oZxForm.getZxType());
		o2oZxEntity.setBillCode(o2oZxServiceImpl.buildCode("O2OZX"));
		O2oLoanUserEntityZx o2oLoanUserEntityZx = O2oUserZxTransFormart.customerNewToloanUser(new O2oLoanUserEntityZx(), customer, o2oZxEntity.getId());
		o2oZxServiceImpl.saveEntityById(o2oZxEntity, o2oLoanUserEntityZx);
		return BaseRestResult.info("保存成功,请上传附件").andRedirect(UrlHelper.build("/o2ozx/findO2oZx?id=" + o2oZxEntity.getId()));
	}

	/**
	 * 附件上传 局部刷新DIV
	 * 
	 * @param loanapplyNo
	 * @param massege
	 * @return
	 */
	@RequestMapping(value = "/uploadFile")
	public HtmlRestResult loanDetail(String id) {

		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(id);
		/**** 查询附件 ****/
		List<O2oDataListEntity> o2oDataList = o2oDataListService.findByEntityList(id);

		O2oLoanUserEntityZx o2oLoanUserEntityZx = o2oLoadUserZxServiceImpl.getEntityByZxNo(id);

		ViewContext.put("o2oDataList", o2oDataList);
		ViewContext.put("o2oZxEntity", o2oZxEntity);
		ViewContext.put("o2oLoanUserEntityZx", o2oLoanUserEntityZx);
		return new HtmlRestResult("o2ozx/uploadfileDiv");
	}

	/**
	 * 新征信动态表单 附件上传 局部刷新DIV
	 * 
	 * @param id
	 * @param massege
	 * @return
	 */
	@RequestMapping(value = "/newZXzbzxqr")
	public HtmlRestResult newZXzbzxqr(String id) {

		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(id);
		/**** 查询附件 ****/
		List<O2oDataListEntity> o2oDataList = o2oDataListService.findByEntityList(id);

		O2oLoanUserEntityZx o2oLoanUserEntityZx = o2oLoadUserZxServiceImpl.getEntityByZxNo(id);

		List<O2oDataListEntity> dataList = o2oDataListService.findByEntityList(id);
		O2oDataListEntity ZXBGDATAEntity = null;
		O2oDataListEntity WarrantZXBGDATAEntity = null;
		for (int i = 0; i < dataList.size(); i++) {
			O2oDataListEntity entity = dataList.get(i);
			if (entity.getDatalistCode().equals(FileTypeConstants.DALIST_TYPE_ZXBGDATA)) {
				ZXBGDATAEntity = entity;
			}
			if (FileTypeConstants.DALIST_TYPE_Warrant_ZXBGDATA.equals(entity.getDatalistCode())) {
				WarrantZXBGDATAEntity = entity;
			}
		}

		ViewContext.put("WarrantZXBGDATAEntity", WarrantZXBGDATAEntity);
		ViewContext.put("ZXBGDATAEntity", ZXBGDATAEntity);
		ViewContext.put("o2oDataList", o2oDataList);
		ViewContext.put("o2oZxEntity", o2oZxEntity);
		ViewContext.put("o2oLoanUserEntityZx", o2oLoanUserEntityZx);
		return new HtmlRestResult("workflowcheck/newzx_zbzxqr_uploadDiv");
	}

	/**
	 * @Title:
	 * @Description: 征信信息模块(读取service的)
	 * @author 余勇
	 * @return
	 * @return String
	 * @throws @date 2017年7月4日 下午2:17:31
	 */
	@RequestMapping("/loanerZxView")
	public BaseRestResult<String> loanServiceView(String id, String type, String approvalStatus) {

		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(id);
		O2oLoanUserEntityZx o2oLoanUserEntityZx = o2oLoadUserZxServiceImpl.getEntityByZxNo(id);
		O2oLoanUserEntityZx o2oLoanUserEntityZx_sensitive = o2oLoadUserZxServiceImpl.getEntityByZxNo_sensitive(id);// 脱敏

		ViewContext.put("type", type);
		ViewContext.put("approvalStatus", approvalStatus);
		ViewContext.put("o2oZxEntity", o2oZxEntity);
		ViewContext.put("o2oLoanUserEntityZx", o2oLoanUserEntityZx);
		ViewContext.put("o2oLoanUserEntityZx_sensitive", o2oLoanUserEntityZx_sensitive);
		return HtmlRestResult.html("/o2ozx/loanerZxView");
	}

	/**
	 * CXW 显示征信查询详情客户联系电话和证件号码
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping("/show_window")
	public BaseRestResult<String> show_window(String id) {
		O2oLoanUserEntityZx o2oLoanUserEntityZx = o2oLoadUserZxServiceImpl.getEntityByZxNo(id);
		ViewContext.put("vo", o2oLoanUserEntityZx);
		return HtmlRestResult.popHtmlFragment("/o2ozx/zx_show_info");
	}

	/**
	 * @Title:
	 * @Description: 征信资料信息
	 * @author 余勇
	 * @return
	 * @return String
	 * @throws @date 2017年7月4日 下午2:17:31
	 */
	@RequestMapping("/ZxZlView")
	public BaseRestResult<String> ZxZlView(String id) {

		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(id);
		O2oLoanUserEntityZx o2oLoanUserEntityZx = o2oLoadUserZxServiceImpl.getEntityByZxNo(id);

		ViewContext.put("o2oZxEntity", o2oZxEntity);
		ViewContext.put("o2oLoanUserEntityZx", o2oLoanUserEntityZx);
		return HtmlRestResult.html("/o2ozx/ZxZlView");
	}

	/**
	 * @Description: <p>
	 *               脱敏_中行送审数据
	 *               </p>
	 * @author LMX
	 */
	@RequestMapping(value = "/queryBCSsDataView")
	public HtmlRestResult queryBCSsDataView(String id) {
		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(id);
		ViewContext.put("o2oZxEntity", o2oZxEntity);
		return HtmlRestResult.popHtmlFragment("/o2ozx/BCSsData_queryView");
	}

	/**
	 * @Description: <p>
	 *               中行送审数据
	 *               </p>
	 * @author LMX
	 * @date 2018年1月8日 下午2:45:03
	 */
	@RequestMapping("/BcBankSsDataView")
	public BaseRestResult<String> BcBankSsDataView(String id, String approvalStatus) {
		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(id);
		ViewContext.put("o2oZxEntity", o2oZxEntity);
		ViewContext.put("approvalStatus", approvalStatus);
		return HtmlRestResult.html("/o2ozx/BcSsDataView");
	}

	/**
	 * @Description: <p>
	 *               编辑中行送审数据
	 *               </p>
	 * @author LMX
	 * @date 2018年1月8日 下午2:45:03
	 */
	@RequestMapping("/BcBankSsDataUpdate")
	public BaseRestResult<String> BcBankSsDataUpdate(String id) {
		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(id);
		ViewContext.put("o2oZxEntity", o2oZxEntity);
		return HtmlRestResult.html("o2ozx/BcSsDataUpdate");
	}

	/**
	 * @Description: <p>
	 *               保存中行送审数据
	 *               </p>
	 * @author LMX
	 * @date 2018年1月9日 下午2:13:14
	 */
	@RequestMapping("/BcBankSsDataSave")
	public BaseRestResult<String> BcBankSsDataSave(O2oZxVo form) {
		O2oZxEntity o2oZxEntity = null;
		if (form.getId() != null) {
			o2oZxEntity = o2oZxServiceImpl.getEntityById(form.getId());
		} else {
			return BaseRestResult.info("未找到该征信单的id");
		}

		if (o2oZxEntity == null) {
			return BaseRestResult.info("系统中未找到该征信单的信息，请联系管理员");
		}

		if (form.getPurchaseAmount() == null) {
			return BaseRestResult.warn("企业采购金额不能为空");
		}
		if (StringUtil.isBlank(form.getJtdName())) {
			return BaseRestResult.warn("经办平台确认不能为空");
		} else if (form.getJtdName().contains("金融部")) {// 如果经办平台确认字段名称中包含“金融部”三个字
			return BaseRestResult.warn("经办平台不能是省区金融部");
		}

		ActOrgEntity actOrgEntity = null;
		actOrgEntity = sysOrgService.getOrgByUnitNo(form.getJtd());
		o2oZxEntity.setPurchaseAmount(form.getPurchaseAmount());
		o2oZxEntity.setJtd(form.getJtd());
		o2oZxEntity.setJtdCode(actOrgEntity.getUnitCode());
		o2oZxEntity.setJtdName(actOrgEntity.getOrgName());

		User user = UserHolder.getUser();
		o2oZxEntity.setSubmitDate(new Date());
		o2oZxEntity.setSubmitId(user.getNo());
		o2oZxEntity.setSubmitName(user.getCname());

		int i = o2oZxServiceImpl.update(o2oZxEntity);
		if (i > 0) {
			ViewContext.put("o2oZxEntity", o2oZxEntity);
			return BaseRestResult.info("保存成功");
		} else {
			return BaseRestResult.warn("保存失败");
		}
	}

	/**
	 * @Title:
	 * @Description: 征信详情附件
	 * @author 余勇
	 * @return
	 * @return String
	 * @throws @date 2017年9月12日 下午2:17:31
	 */
	@RequestMapping("/detailUploadView")
	public BaseRestResult<String> detailUploadView(String id, String readonly) {
		if (StringUtil.isBlank(readonly)) {
			readonly = "false";
		}
		o2oZxServiceImpl.queryDatalist(id, readonly);
		return HtmlRestResult.html("o2ozx/detailUploadView");
	}
	

	/**
	 * @Description: <p>
	 *               夫妻双方历史征信报告
	 *               </p>
	 * @author LMX
	 * @date 2018年1月22日 下午3:04:02
	 */
	@RequestMapping("/fqZxHistoryView")
	public BaseRestResult<String> fqZxHistoryView(String loanapplyNo, String loanId, String readonly) {
		if (StringUtil.isBlank(readonly)) {
			readonly = "false";
		}
		o2oZxServiceImpl.queryHistoryfqZx(loanapplyNo, loanId, readonly);
		return HtmlRestResult.html("o2ozx/historyFqZxView");
	}

	/**
	 * @Description: <p>
	 *               企业历史征信报告
	 *               </p>
	 * @author LMX
	 * @date 2018年1月22日 下午3:04:02
	 */
	@RequestMapping("/qyZxHistoryView")
	public BaseRestResult<String> qyZxHistoryView(String loanapplyNo, String loanId, String readonly) {
		if (StringUtil.isBlank(readonly)) {
			readonly = "false";
		}
		o2oZxServiceImpl.queryHistoryQyZx(loanapplyNo, loanId, readonly);
		return HtmlRestResult.html("o2ozx/historyQyZxView");
	}

	/**
	 * @Description: <p>
	 *               删除征信
	 *               </p>
	 * @author CXW
	 * @date 2017年9月27日 下午2:39:19
	 * @version V1.0
	 */
	@RequestMapping("/delete")
	public BaseRestResult<String> deleteO2oZx(String id) {
		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(id);
		o2oZxEntity.setIsDel(StatusContexts.O2O_YES);
		int i = o2oZxServiceImpl.update(o2oZxEntity);
		if (i > 0) {
			return BaseRestResult.info("删除成功！").andRedirect("/o2ozx/list");
		}
		return BaseRestResult.warn("删除失败！");
	}

	/**
	 * @Description: <p>
	 *               删除征信
	 *               </p>
	 * @author CXW
	 * @date 2017年9月27日 下午2:39:19
	 * @version V1.0
	 */
	@RequestMapping("/deleteNew")
	public BaseRestResult<String> deleteO2oZxNew(String id) {
		try {
			O2oZxSulpmentEntity zxSulpmentEntity = o2oZxServiceImpl.getZxEntityById(id);
			zxSulpmentEntity.setIsDelete(StatusContexts.O2O_YES);
			int i = o2oZxServiceImpl.update(zxSulpmentEntity);
			if (i > 0) {
				O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(zxSulpmentEntity.getZxNo());
				O2oZxSulpmentRecordLogEntity entity = new O2oZxSulpmentRecordLogEntity();
				entity.setAction("删除征信报告");
				entity.setLoanapplyNo(zxSulpmentEntity.getLoanapplyNo());
				entity.setBillCode(o2oZxEntity.getBillCode());
				entity.setOperationTime(new Date());
				entity.setZxNo(zxSulpmentEntity.getZxNo());
				User user = UserHolder.getUser();
				entity.setUpdateNo(user.getNo());
				entity.setUpdateName(user.getCname());
				o2oZxServiceImpl.insert(entity);
				return BaseRestResult.info("删除成功！").andJquerySelectAjaxAction("#refreshDiv");
			}
		} catch (Exception e) {
			logger.error("delete O2oZxSulpmentEntity error,msg:【{}】", e.getMessage());
		}
		return BaseRestResult.warn("删除失败！");
	}

	/**
	 * 修改申请征信信息
	 * 
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/updateO2oZx", method = RequestMethod.POST)
	public BaseRestResult<String> updateO2oZx(AddO2oZxForm addO2oZxForm) {
		logger.info("修改addO2oZxForm=={}", addO2oZxForm.toString());
		ActOrgEntity actOrgEntity = null;
		actOrgEntity = sysOrgService.getOrgByUnitNo(addO2oZxForm.getLtd());
		O2oZxEntity o2oZxEntity = null;
		if (addO2oZxForm.getId() != null) {
			o2oZxEntity = o2oZxServiceImpl.getEntityById(addO2oZxForm.getId());
		} else {
			return BaseRestResult.info("未找到该征信单的id");
		}

		if (o2oZxEntity == null) {
			return BaseRestResult.info("系统中未找到该征信单的信息，请联系管理员");
		}
		O2oLoanUserEntityZx o2oLoanUserEntityZx = o2oLoadUserZxServiceImpl.getEntityByZxNo(addO2oZxForm.getId());
		if (!StatusContexts.O2O_BANKTYPE_BC.equals(addO2oZxForm.getZxBank())) {
			Boolean isMothSelected = o2oZxServiceImpl.isMothSelectedZX(o2oLoanUserEntityZx.getDocumentNo(), addO2oZxForm.getZxBank());
			if (isMothSelected) {
				return BaseRestResult.warn("一个自然月内在同一家银行仅能查询一次个人征信报告");
			}
		}

		o2oZxEntity.setIsDel(StatusContexts.O2O_NO);
		o2oZxEntity.setLtd(addO2oZxForm.getLtd());
		o2oZxEntity.setZxStatus(StatusContexts.O2O_NEW);
		o2oZxEntity.setLtdName(actOrgEntity.getOrgName());
		o2oZxEntity.setLtdCode(actOrgEntity.getUnitCode());
		o2oZxEntity.setOperatorId(addO2oZxForm.getOperatorNo());
		o2oZxEntity.setOperatorName(addO2oZxForm.getOperatorName());
		o2oZxEntity.setZxBank(addO2oZxForm.getZxBank());
		o2oZxEntity.setZxType(addO2oZxForm.getZxType());
		o2oZxServiceImpl.update(o2oZxEntity);
		return BaseRestResult.info("保存成功").andRedirect(UrlHelper.build("/o2ozx/detail?id=" + addO2oZxForm.getId()));
	}

	/**
	 * @Title: loanFqZxbg
	 * @Description: 征信选着模块局部刷新DIV
	 * @author 张庆奇
	 * @param loanapplyNo
	 * @param IdNum
	 * @return
	 * @return HtmlRestResult
	 * @throws @date 2017年9月6日 下午1:43:12
	 */
	@RequestMapping(value = "/loanFqZxbg")
	public HtmlRestResult loanFqZxbg(String loanapplyNo, String IdNum) {
		PageResult<Object[]> pageResult = o2oLoadUserZxServiceImpl.loanFqZxbg(IdNum);
		String[] titles = { "征信单据", "客户姓名", "证件号码", "银行征信报告日期", "第三方征信报告日期", "征信创建日期", "状态" };
		PaginationInfo paginationInfo = new PaginationInfo(pageResult, titles);
		SelectDataOption[] selectDataOptions = { null, null, null, null, null, null, new SelectDataOption("O2O_BILLSTATUS") };
		paginationInfo.setSelectDataOptions(selectDataOptions);
		paginationInfo.setBuildPagingNavigation(false);
		paginationInfo.setFirstRenderColumnIndex(1);
		paginationInfo.setBuildSelectBox(true);
		ViewContext.put("paginationInfo", paginationInfo);
		ViewContext.put("loanapplyNo", loanapplyNo);
		return HtmlRestResult.popHtmlFragment("/o2ozx/loanFqZxbg");

	}

	/**
	 * 申请征信
	 * 
	 * @Title: zxbgView
	 * @Description: 夫妻双方征信报告模块
	 * @author 张庆奇
	 * @param customerId
	 * @return
	 * @return BaseRestResult<String>
	 * @throws
	 * @date 2017年9月5日 下午6:22:55
	 */
	@RequestMapping("/zxbgNewView")
	public HtmlRestResult zxbgNewView(String loanapplyNo) {

		PageResult<Object[]> paymentsResult = o2oZxServiceImpl.queryFqZxbgNew(loanapplyNo);
		String[] paymentstitles = { "征信单号", "姓名", "征信银行", "银行征信报告时间", "第三方征信报告时间", "更新时间", "更新人", "征信状态" };
		PaginationInfo paginationInfo = new PaginationInfo(paymentsResult, paymentstitles);
		SelectDataOption[] selectDataOptions = { null, null, new SelectDataOption("BANKTYPEO2O"), null, null, null, null, new SelectDataOption("O2O_BILLSTATUS") };
		paginationInfo.setSelectDataOptions(selectDataOptions);
		paginationInfo.setBuildPagingNavigation(false);
		paginationInfo.setFirstRenderColumnIndex(2);
		paginationInfo.setBuildRowNumber(true);
		Button createButton = ButtonHelper.createAjaxConfirmButton("删除", "/ro2ozx/deleteNew?id=", "deleteZxNewBtn");
		Button[] moreButtons = new Button[] { createButton };
		paginationInfo.setMoreButtons(moreButtons);
//		Button[] titleButton = new Button[] { ButtonHelper.createRedirectButton(null, "/o2ozx/detail?id=") };
//		paginationInfo.setTitleButtons(titleButton);
		ViewContext.put("paginationInfo", paginationInfo);
		ViewContext.put("loanapplyNo", loanapplyNo);
		return new HtmlRestResult("/o2ozx/zxbgNewView");
	}

	/**
	 * @Title: loanFqZxbgNew
	 * @Description: 面签申报详情页面补充征信按钮
	 * @author CXW
	 * @param loanapplyNo
	 * @return
	 * @return HtmlRestResult
	 * @throws @date 2018年3月7日 下午10:43:12
	 */
	@RequestMapping(value = "/loanFqZxbgNew")
	public HtmlRestResult loanFqZxbgNew(String loanapplyNo) {
		O2oLoanapplyEntity o2oloanapply = o2oLoanapplyService.findById(loanapplyNo);
		O2oLoanUserEntity customer = o2oLoanUserService.findById(o2oloanapply.getLoanId(), loanapplyNo);
		O2oLoanUserEntity customerD = o2oLoanUserService.findSponsorById(o2oloanapply.getLoanId(), loanapplyNo);
		O2oLoanUserEntity customerS = o2oLoanUserService.findSpouseId(o2oloanapply.getLoanId(), loanapplyNo);
		String documentNoC = customer.getDocumentNo();
		String documentNoD = "";
		if (customerD != null && customerD.getDocumentNo() != null) {
			documentNoD = customerD.getDocumentNo();
		}
		String documentNoS = "";
		if (customerS != null && customerS.getDocumentNo() != null) {
			documentNoS = customerS.getDocumentNo();
		}
		String documentNo = "'" + documentNoC + "','" + documentNoD + "','" + documentNoS + "'";
		PageResult<Object[]> pageResult = o2oLoadUserZxServiceImpl.loanFqZxbgNew(documentNo, o2oloanapply.getBankLoanName());
		String[] titles = { "征信单据", "客户姓名", "证件号码", "银行征信报告日期", "第三方征信报告日期", "征信创建日期", "状态" };
		PaginationInfo paginationInfo = new PaginationInfo(pageResult, titles);
		SelectDataOption[] selectDataOptions = { null, null, null, null, null, null, new SelectDataOption("O2O_BILLSTATUS") };
		paginationInfo.setSelectDataOptions(selectDataOptions);
		paginationInfo.setBuildPagingNavigation(false);
		paginationInfo.setFirstRenderColumnIndex(1);
		paginationInfo.setBuildSelectBox(true);
		ViewContext.put("paginationInfo", paginationInfo);
		ViewContext.put("loanapplyNo", loanapplyNo);
		return HtmlRestResult.popHtmlFragment("/o2ozx/loanFqZxbgNew");

	}

	/**
	 * @Title: zxConfirm
	 * @Description: 选着征信确认
	 * @author 张庆奇
	 * @param loanapplyNo
	 * @param request
	 * @return
	 * @return HtmlRestResult
	 * @throws @date 2017年9月6日 下午2:46:18
	 */
	@RequestMapping("/zxConfirm")
	public BaseRestResult<String> zxConfirm(String loanapplyNo, HttpServletRequest request) {
		String[] selectedZx = request.getParameterValues("ids");
		if (selectedZx == null || selectedZx.length == 0) {
			return BaseRestResult.warn("请选中需要的征信报告");

		}
		if (selectedZx.length > 1) {
			return BaseRestResult.warn("只能选着一个征信报告");
		}

		String zxUserId = selectedZx[0];
		O2oLoanUserEntityZx zxUser = o2oLoadUserZxServiceImpl.getEntityById(zxUserId);
		O2oLoanUserEntity userEntity = o2oLoanUserService.findById(zxUser.getLoanId(), loanapplyNo);
		if (userEntity != null) {
			userEntity.setZxNo(zxUser.getZxNo());
			userEntity.setRelationDate(new Date());
			userEntity.setRelationId(userUtils.getUser().getNo());
			userEntity.setRelationName(userUtils.getUser().getCname());
			o2oLoanUserService.updateLoanUserEntity(userEntity);
		}

		// 2.启动征信报告流程
		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(zxUser.getZxNo());
		if ("NEW".equals(o2oZxEntity.getZxStatus())) {
			PayMentForm payform = new PayMentForm();
			String mateId = "";
			payform.setLoanapplyNo(zxUser.getZxNo());
			if (o2oZxEntity.getZxType().equals("ZX_JKR")) {
				mateId = o2oLoanUserService.findMateUserEntity(loanapplyNo);
			} else if (o2oZxEntity.getZxType().equals("ZX_PO")) {
				mateId = userEntity.getSpouseId();
			}
			if (StringUtils.isNotEmpty(mateId)) {
				payform.setMaterId(mateId);
			}
			boolean flag = checkZxbgstartup(payform);
			boolean isOk = true;
			if (flag) {
				isOk = zxbgstartup(payform);
			}

			if (!flag || !isOk) {

				sendMessage(payform);
			}
		}
		return HtmlRestResult.buildClosestReloadResult();
	}

	/**
	 * @Title: zxConfirmNew
	 * @Description: 选着补充征信确认
	 * @author CXW
	 * @param loanapplyNo
	 * @param request
	 * @return
	 * @return HtmlRestResult
	 * @throws @date 2018年3月7日 下午2:46:18
	 */
	@RequestMapping("/zxConfirmNew")
	public BaseRestResult<String> zxConfirmNew(String loanapplyNo, HttpServletRequest request) {
		try {
			String[] selectedZx = request.getParameterValues("ids");
			if (selectedZx == null || selectedZx.length == 0) {
				return BaseRestResult.warn("请选中需要的征信报告");

			}
			if (selectedZx.length > 1) {
				return BaseRestResult.warn("只能选着一个征信报告");
			}
			User user = UserHolder.getUser();
			String zxUserId = selectedZx[0];
			O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(zxUserId);
			O2oZxSulpmentEntity o2oZxSulpmentEntity = o2oZxServiceImpl.getZxEntityByZxId(o2oZxEntity.getId());
			if (null == o2oZxSulpmentEntity) {
				o2oZxSulpmentEntity = new O2oZxSulpmentEntity();
				o2oZxSulpmentEntity.setIsDelete(StatusContexts.O2O_NO);
				o2oZxSulpmentEntity.setLoanapplyNo(loanapplyNo);
				o2oZxSulpmentEntity.setZxNo(o2oZxEntity.getId());
				o2oZxSulpmentEntity.setRelationDate(new Date());
				o2oZxSulpmentEntity.setRelationId(user.getNo());
				o2oZxSulpmentEntity.setRelationName(user.getCname());
				int i = o2oZxServiceImpl.insert(o2oZxSulpmentEntity);
				if (i > 0) {
					O2oZxSulpmentRecordLogEntity entity = new O2oZxSulpmentRecordLogEntity();
					entity.setAction("关联征信报告");
					entity.setLoanapplyNo(o2oZxSulpmentEntity.getLoanapplyNo());
					entity.setBillCode(o2oZxEntity.getBillCode());
					entity.setOperationTime(new Date());
					entity.setZxNo(o2oZxSulpmentEntity.getZxNo());
					entity.setUpdateNo(user.getNo());
					entity.setUpdateName(user.getCname());
					o2oZxServiceImpl.insert(entity);
				}
			}
			return BaseRestResult.info("添加成功").andCloseActionDialog().andJquerySelectAjaxAction("#refreshDiv");
		} catch (Exception e) {
			return BaseRestResult.info("添加失败").andJquerySelectAjaxAction("#refreshDiv");
		}
		// return HtmlRestResult.buildClosestReloadResult();
	}

	@RequestMapping("/view")
	public BaseRestResult<String> loanView(String customerId) {
		CustomerEntity customer = customerService.queryCustomerEntityByCustomerId(customerId);
		ViewContext.put("vo", customer);
		return HtmlRestResult.html("/o2ozx/loanerView");
	}

	/**
	 * @Description: <p>
	 *               根据客户身份证查询贷款次数
	 *               </p>
	 * @author yy
	 * @date 2017年7月14日 上午11:02:30
	 * @version V1.0
	 */
	@RequestMapping(value = "/checkO2ozx")
	public BaseRestResult<?> checkLoan(String idCard) {
		idCard = idCard.trim();
		O2oRecommendEntity entity = o2oRecommendService.findEntityByCard(idCard);
		if (null != entity) {
			User user = UserHolder.getUser();
			if (!entity.getOperatorNo().equals(user.getNo())) {
				return BaseRestResult.warn("is_recomment");
			}
		}
		int o2oZXI = o2oLoadUserZxServiceImpl.checkO2ozx(idCard);
		if (o2oZXI > 0) {
			// 该申请人人在新系统中已存在新建或流程中的单
			return BaseRestResult.warn("is_user_zx");
		}
		return BaseRestResult.warn("success");

	}
	
	@RequestMapping("/supplement_index")
	public BaseRestResult<String> supplement_index(String loanapplyNo){
		ViewContext.put("loanapplyNo", loanapplyNo);
		return HtmlRestResult.popHtmlFragment("/o2ozx/supplement_index");
	}

	@RequestMapping(value = "/applyZx")
	public BaseRestResult<String> applyZx(String loanapplyNo, String IdNum) {
		O2oLoanapplyEntity loanapplyEntity = o2oLoanapplyService.findById(loanapplyNo);
		O2oLoanUserEntity userEntity = o2oLoanUserService.findBySomeone(loanapplyNo, IdNum);
		CustomerBasicInfo customer = o2oLoanapplyService.getCustomerEntityById(userEntity.getId());
		O2oRecommendEntity entity = o2oRecommendService.findEntityByCard(userEntity.getDocumentNo());
		if (null != entity) {
			User user = UserHolder.getUser();
			if (!entity.getOperatorNo().equals(user.getNo())) {
				return BaseRestResult.warn("该客户目前由其他信贷经理对接，暂无法跟进");
			}
		}
		if (StringUtils.isEmpty(loanapplyEntity.getOperatorNo())) {
			return BaseRestResult.warn("信贷经理不能为空");
		}

		if (StringUtils.isEmpty(loanapplyEntity.getLtd())) {
			return BaseRestResult.warn("经办平台不能为空");
		}

		int o2oZXI = o2oLoadUserZxServiceImpl.checkO2ozx(IdNum);
		if (o2oZXI > 0) {
			// 该申请人人在新系统中已存在新建或流程中的单
			return BaseRestResult.warn("该申请人人在新系统中已存在新建或流程中的单");
		}

		ActOrgEntity actOrgEntity = null;
		actOrgEntity = sysOrgService.getOrgByUnitNo(loanapplyEntity.getLtd());
		O2oZxEntity o2oZxEntity = new O2oZxEntity();
		o2oZxEntity.setCreateId(userUtils.getUser().getNo());
		o2oZxEntity.setCreateDate(new Date());
		o2oZxEntity.setCreateName(userUtils.getUser().getCname());
		o2oZxEntity.setIsDel(StatusContexts.O2O_NO);
		o2oZxEntity.setLtd(loanapplyEntity.getLtd());
		o2oZxEntity.setZxStatus(StatusContexts.O2O_NEW);
		o2oZxEntity.setLtdName(actOrgEntity.getOrgName());
		o2oZxEntity.setLtdCode(actOrgEntity.getUnitCode());
		o2oZxEntity.setOperatorId(loanapplyEntity.getOperatorNo());
		o2oZxEntity.setOperatorName(loanapplyEntity.getOperatorName());
		if (userEntity.getSpouseId() == null) {
			o2oZxEntity.setZxType("ZX_JKR");

		} else {
			o2oZxEntity.setZxType("ZX_PO");

		}
		o2oZxEntity.setBillCode(o2oZxServiceImpl.buildCode("O2OZX"));
		O2oLoanUserEntityZx o2oLoanUserEntityZx = O2oUserZxTransFormart.customerAdminToloanUser(new O2oLoanUserEntityZx(), userEntity, customer);
		String zxId = o2oZxServiceImpl.saveNewEntityById(o2oZxEntity, o2oLoanUserEntityZx);

		return BaseRestResult.popHtmlFragmentUrl("/ro2ozx/applyZx1?zxId=" + zxId + "&loanapplyNo=" + loanapplyNo);

	}

	@RequestMapping(value = "/applyZx1")
	public HtmlRestResult applyZx1(String zxId, String loanapplyNo) {
		O2oZxEntity zxEntity = o2oZxServiceImpl.getEntityById(zxId);

		O2oLoanUserEntityZx zxuser = o2oLoadUserZxServiceImpl.getEntityByZxNo(zxId);
		if ("ZX_JKR".equals(zxEntity.getZxType())) {
			ViewContext.put("customerType", "借款人");
		} else if ("ZX_PO".equals(zxEntity.getZxType())) {
			ViewContext.put("customerType", "配偶");
		}
		ViewContext.put("zxEntity", zxEntity);
		ViewContext.put("zxuser", zxuser);
		ViewContext.put("loanapplyNo", loanapplyNo);
		return HtmlRestResult.popHtmlFragment("/o2ozx/applyZx");

	}

	/**
	 * @Title: updateZxAndZxzr
	 * @Description: 修改征信查询有关信息，并且启动流程，关联征信报告
	 * @author 张庆奇
	 * @param addO2oZxForm
	 * @return
	 * @return BaseRestResult<String>
	 * @throws
	 * @date 2017年10月12日 下午4:32:48
	 */
	@RequestMapping(value = "/updateZxAndZxzr", method = RequestMethod.POST)
	public BaseRestResult<String> updateZxAndZxzr(O2oZxEntity zxEntity) {
		logger.info("修改zxEntity=={}", zxEntity.toString());
		ActOrgEntity actOrgEntity = null;
		actOrgEntity = sysOrgService.getOrgByUnitNo(zxEntity.getLtd());
		O2oZxEntity o2oZxEntity = null;
		if (zxEntity.getId() != null) {
			o2oZxEntity = o2oZxServiceImpl.getEntityById(zxEntity.getId());
		} else {
			return BaseRestResult.info("未找到该征信单的id");
		}

		if (o2oZxEntity == null) {
			return BaseRestResult.info("系统中未找到该征信单的信息，请联系管理员");
		}

		if (StringUtils.isEmpty(zxEntity.getOperatorId())) {
			return BaseRestResult.warn("信贷经理不能为空");
		}

		if (StringUtils.isEmpty(zxEntity.getLtd())) {
			return BaseRestResult.warn("经办平台不能为空");
		}

		if (StringUtils.isEmpty(zxEntity.getZxBank())) {
			return BaseRestResult.warn("征信银行不能为空");
		}

		O2oLoanUserEntityZx o2oLoanUserEntityZx=o2oLoadUserZxServiceImpl.getEntityByZxNo(zxEntity.getId());
		//
		if (!StatusContexts.O2O_BANKTYPE_BC.equals(zxEntity.getZxBank())) {
			Boolean isMothSelected = o2oZxServiceImpl.isMothSelectedZX(o2oLoanUserEntityZx.getDocumentNo(), zxEntity.getZxBank());
			if (isMothSelected) {
				return BaseRestResult.warn("一个自然月内在同一家银行仅能查询一次个人征信报告");
			}
		}
		
		// 1.更新征信报告信息
		o2oZxEntity.setIsDel(StatusContexts.O2O_NO);
		o2oZxEntity.setLtd(zxEntity.getLtd());
		o2oZxEntity.setZxStatus(StatusContexts.O2O_NEW);
		o2oZxEntity.setLtdName(actOrgEntity.getOrgName());
		o2oZxEntity.setLtdCode(actOrgEntity.getUnitCode());
		o2oZxEntity.setOperatorId(zxEntity.getOperatorId());
		o2oZxEntity.setOperatorName(zxEntity.getOperatorName());
		o2oZxEntity.setZxBank(zxEntity.getZxBank());
		o2oZxServiceImpl.update(o2oZxEntity);

		O2oLoanUserEntity userEntity = o2oLoanUserService.findById(o2oLoanUserEntityZx.getLoanId(), zxEntity.getLoanapplyNo());
		// 2.启动征信报告流程
		PayMentForm payform = new PayMentForm();
		String mateId = "";
		payform.setLoanapplyNo(o2oZxEntity.getId());
		if (o2oZxEntity.getZxType().equals("ZX_JKR")) {
			mateId = o2oLoanUserService.findMateUserEntity(zxEntity.getLoanapplyNo());
		} else if (o2oZxEntity.getZxType().equals("ZX_PO")) {
			mateId = userEntity.getSpouseId();
		}
		if (StringUtils.isNotEmpty(mateId)) {
			payform.setMaterId(mateId);
		}

		boolean flag = checkZxbgstartup(payform);
		boolean isOk = true;
		if (flag) {
			isOk = zxbgstartup(payform);
		}

		if (!flag || !isOk) {

			sendMessage(payform);
		}
		// 4.启动成功，关联征信准入信息

		if (userEntity != null) {
			userEntity.setZxNo(o2oLoanUserEntityZx.getZxNo());
			userEntity.setRelationDate(new Date());
			userEntity.setRelationId(userUtils.getUser().getNo());
			userEntity.setRelationName(userUtils.getUser().getCname());
			o2oLoanUserService.updateLoanUserEntity(userEntity);
		}

		return BaseRestResult.buildClosestReloadResult();
	}

	/**
	 * @Title: checkZxbgstartup
	 * @Description:校验是否能够启动征信报告流程
	 * @author 张庆奇
	 * @param payform
	 * @return
	 * @return boolean
	 * @throws
	 * @date 2017年10月18日 上午10:25:57
	 */
	private boolean checkZxbgstartup(PayMentForm payform) {
		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(payform.getLoanapplyNo());
		logger.info("贷款对象：{}", o2oZxEntity);
		if (!o2oDataListService.checkDataCode(o2oZxEntity.getId(), null)) {
			return false;
		}

		if (StringUtils.isEmpty(o2oZxEntity.getZxBank())) {
			return false;
		}

		return true;
	}

	/**
	 * @Title: zxbgstartup
	 * @Description:启动征信报告流程
	 * @author 张庆奇
	 * @param payform
	 * @return
	 * @return BaseRestResult<String>
	 * @throws
	 * @date 2017年10月17日 下午4:19:01
	 */
	private boolean zxbgstartup(PayMentForm payform) {
		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(payform.getLoanapplyNo());
		logger.info("贷款对象：{}", o2oZxEntity);
		O2oLoanUserEntityZx o2oLoanUserEntityZx = o2oLoadUserZxServiceImpl.getEntityByZxNo(payform.getLoanapplyNo());
		WFRequestParam param = new WFRequestParam();
		param.setReferId(o2oZxEntity.getId());
		param.setReferCode(o2oZxEntity.getBillCode());
		param.setReferUrl(NewZxUrl);
		param.setSystemModule(ProcessTemplate.SYSTEM_MODULE_O2O);
		param.setProcessType(StatusContexts.WF_TYPE_CREDIT_INQUIRY);
		param.setProcessVersion("v1");
		User user = UserHolder.getUser();
		param.setAppliedby(o2oZxEntity.getCreateId());
		param.setAppliedbyName(o2oZxEntity.getCreateName());
		param.setOrgNo(o2oZxEntity.getLtd());
		// param.setReferUrl(backfeeUrl + "?billCode=" +
		// o2oZxEntity.getId()+"&type=1");
		StringBuffer appliedDes = new StringBuffer("姓名:");
		appliedDes.append(o2oLoanUserEntityZx.getUserFullName());
		appliedDes.append("，客户类型:" + o2oPubDdItemService.findPubdditemO2ONameByCode("ZX_TYPE", o2oZxEntity.getZxType()));
		appliedDes.append("，征信银行:" + o2oPubDdItemService.findPubdditemNameByCodeisall("BANKTYPEO2O", o2oZxEntity.getZxBank()));
		param.setAppliedDes(appliedDes.toString());
		logger.info("提交征信，参数有征信id：【{}】，征信编号：【{}】，系统模块：【{}】，流程类型：【{}】，经营平台id：【{}】，贷款摘要信息：【{}】", o2oZxEntity.getId(), o2oZxEntity.getBillCode(), ProcessTemplate.SYSTEM_MODULE_O2O, param.getProcessType(), o2oZxEntity.getLtd(), appliedDes.toString());
		ModelResult<Boolean> modelResult = workFlowService.instance(param);
		if (modelResult.isSuccess() && modelResult.getModel()) {
			o2oZxEntity.setZxStatus(StatusContexts.WFTYPE_STATUS_RUN);
			o2oZxEntity.setSubmitId(user.getNo());
			o2oZxEntity.setSubmitName(user.getCname());
			o2oZxEntity.setSubmitDate(new Date());
			o2oZxServiceImpl.update(o2oZxEntity);
		} else {

			logger.error("提交征信流程失败，错误信息{}", modelResult.getDetailStack());
			return false;
		}
		return true;

	}

	private void sendMessage(PayMentForm payform) {

		O2oZxEntity o2oZxEntity = o2oZxServiceImpl.getEntityById(payform.getLoanapplyNo());
		logger.info("贷款对象：{}", o2oZxEntity);
		O2oLoanUserEntityZx o2oLoanUserEntityZx = o2oLoadUserZxServiceImpl.getEntityByZxNo(payform.getLoanapplyNo());
		User user = UserHolder.getUser();
		// 3.失败发送短信
		ModelResult<User> result = sysPermissionService.getSysUserById(o2oZxEntity.getOperatorId());// 信贷经理id
		User operator = result.getModel();
		SmsNotifyRequest smsCustomerRequest = new SmsNotifyRequest();
		smsCustomerRequest.setRequestId(o2oZxEntity.getId());
		smsCustomerRequest.setBizCode(o2oZxEntity.getBillCode());
		smsCustomerRequest.setContent("[" + o2oLoanUserEntityZx.getUserFullName() + "]的征信查询流程自动启动失败，请人工发起征信查询流程。");
		smsCustomerRequest.setRecipientNumber(operator.getMobile());
		smsCustomerRequest.setRequestDateTime(new Date());
		smsCustomerRequest.setSmsSendType(SmsSendType.INSTANT);
		smsCustomerRequest.setSystemCode("业务系统");
		smsCustomerRequest.setReceiveName(user.getCname());
		smsCustomerRequest.setSendName("系统");
		try {
			logger.info("征信报告编号：[{}],发送信贷经理手机号:[{}]", o2oZxEntity.getBillCode(), operator.getMobile());
			com.eascs.notify.constant.ModelResult<SmsNotifyResponse> response = smsNotifier.notify(smsCustomerRequest);
			if (!response.isSuccess()) {

				logger.info("征信报告编号：[{}],发送信贷经理短信发送失败原因:{}", o2oZxEntity.getBillCode(), response.getErrMsg());
			}
		} catch (Exception e) {
			logger.error("征信报告编号：[{}],发送信贷经理短信发送异常:{}", o2oZxEntity.getBillCode(), e.getMessage());

		}
	}

	/**
	 * @Title: tkdetailUploadView
	 * @Description: 征信详情页面查看附件弹出页面
	 * @author 张庆奇
	 * @param id
	 * @param readonly
	 * @return
	 * @return BaseRestResult<String>
	 * @throws
	 * @date 2018年2月6日 上午10:22:42
	 */
	@RequestMapping("/tkdetailUploadView")
	public HtmlRestResult tkdetailUploadView(String id) {

		PageResult<Object[]> pageResult = o2oLoanapplyService.findO2oDataListEntityById(id);
		String titles[] = { "附件类型", "文件名", "提交人", "提交时间", "更新时间" };
		OpenButton fileButton = new OpenButton(null, "/file/download?datalistno=");
		fileButton.setShowButtonFilter(new ShowButtonFilter() {

			@Override
			public boolean filter(Object param) {
				Object[] params = (Object[]) param;
				return !"征信报告".equals(params[1]);
			}

		});
		Button[] detailButton = new Button[] { fileButton };

		PaginationInfo datalistInfo = new PaginationInfo(pageResult, titles);
		datalistInfo.setTitleButtons(detailButton);
		datalistInfo.setBuildPagingNavigation(false);
		datalistInfo.setFirstRenderColumnIndex(1);
		datalistInfo.setBuildRowNumber(true);
		ViewContext.put("datalistInfo", datalistInfo);

		return HtmlRestResult.popHtmlFragment("o2ozx/zxfjView");

	}

}
